<?php $this->headTitle('Управление записями'); ?>

<div id="strlist">
    <div class="strecord">
        <div class="theme">Управление записями</div>
        <?php if (!empty($this->messages)) { ?>
        <div class="messages">
            <?php foreach($this->messages as $message) {
                    echo $message . '<br>';
                } ?>
        </div>
        <?php } ?>
        <?php if (count($this->paginator)) { ?>
        <table>
        <tr>
            <th>Заголовок</th>
            <th>Категория</th>
            <th>Скрытие</th>
            <th>Дата создания</th>
            <th></th>
            <th></th>
        </tr>
        <?php $classTr = 'odd';
        foreach ($this->paginator as $topic) { ?>
            <tr class="<?php echo $classTr; ?>">
            <td style="background-color: #222;"><a href="<?php
                echo $this->url(array('id' => $topic->post_id), 'topic');
            ?>"><?php
            echo $topic->title; ?></a></td>
            <td><?php echo $this->nameCategory[$topic->category_id]; ?></td>
            <?php if ($topic->hide) { ?>
                <td>Да</td>
            <?php } else { ?>
                <td></td>
            <?php } ?>
            <td><?php echo $this->dateTimeFormat($topic->time_created); ?></td>
            <td><a href="<?php
                                echo $this->url(array('id' => $topic->post_id), 'editTopic');
                         ?>">Edit</a></td>
            <td><a href="<?php
                            echo $this->url(array('id' => $topic->post_id), 'deleteTopic');
                         ?>">Delete</a></td>
            </tr>
        <?php
            $classTr = ($classTr == 'odd') ? 'even' : 'odd';
        } ?>
        </table>
        <?php } else { ?>
        <p>У вас ещё нет записей</p>
        <?php } ?>
        <p><a href="<?php
                        echo $this->url(array(), 'addTopic');
                    ?>" class="button">Создать новую запись</a></p>
    </div>
    <?php echo $this->paginationControl($this->paginator, 'Elastic', 'main_paginator.phtml'); ?>
</div>
